home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / ggraph / RCS / symbols.c,v < prev   
Text File  |  1989-07-12  |  11KB  |  320 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     89.07.12.01.41.03;  author douglis;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @baseline from monet (?)
  17. @
  18.  
  19.  
  20.  
  21. 1.1
  22. log
  23. @Initial revision
  24. @
  25. text
  26. @#include <stdio.h>
  27. #include <errno.h>
  28. #include <strings.h>
  29. #include <math.h>
  30. #include "ggraph.h"
  31. #include "ggraphdefs.h"
  32.  
  33. /****************************************************************
  34.  *                                *
  35.  *    putcirclepoint - draw a circle around the point        *
  36.  *                x, y - point to use as center    *
  37.  *                                *
  38.  ****************************************************************/
  39. putcirclepoint (x, y)
  40. float   x,
  41.         y;
  42. {
  43.     if(version == SUN_GREMLIN)
  44.       fprintf (outfile, "ARC\n");
  45.     else
  46.       fprintf (outfile, "%d\n", CIRCLE);
  47.     fprintf(outfile, "%4.1f %4.1f\n", x, y);
  48.     fprintf(outfile, "%4.1f %4.1f\n", x + (SQRT2 * cg.symbolsz), 
  49.                  y + (SQRT2 * cg.symbolsz));
  50.     fprintf(outfile, "%4.1f %4.1f\n", x, y + cg.symbolsz);
  51.     fprintf(outfile, "%4.1f %4.1f\n", x, y - cg.symbolsz);
  52.     fprintf(outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y);
  53.     fprintf(outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y);
  54.  
  55.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  56.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  57. }
  58.  
  59. /****************************************************************
  60.  *                                *
  61.  *    putboxpoint - draw a box around the point        *
  62.  *                x, y - point to use as center    *
  63.  *                                *
  64.  ****************************************************************/
  65. putboxpoint (x, y)
  66. float   x,
  67.         y;
  68. {
  69.     if(version == SUN_GREMLIN)
  70.       fprintf (outfile, "VECTOR\n");
  71.     else
  72.       fprintf (outfile, "%d\n", LINE);
  73.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  74.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y + cg.symbolsz);
  75.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y + cg.symbolsz);
  76.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y - cg.symbolsz);
  77.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  78.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  79.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  80. }
  81.  
  82. /****************************************************************
  83.  *                                *
  84.  *    putcrosspoint - draw a cross on the point        *
  85.  *                x, y - point to use as center    *
  86.  *                                *
  87.  ****************************************************************/
  88. putcrosspoint (x, y)
  89. float   x,
  90.         y;
  91. {
  92.     if(version == SUN_GREMLIN)
  93.       fprintf (outfile, "VECTOR\n");
  94.     else
  95.       fprintf (outfile, "%d\n", LINE);
  96.     fprintf (outfile, "%4.1f %4.1f\n", x, y + cg.symbolsz);
  97.     fprintf (outfile, "%4.1f %4.1f\n", x, y - cg.symbolsz);
  98.     fprintf (outfile, "%4.1f %4.1f\n", x, y);
  99.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y);
  100.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y);
  101.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  102.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  103. }
  104.  
  105. /****************************************************************
  106.  *                                *
  107.  *    putxpoint - draw a star on the point            *
  108.  *                x, y - point to use as center    *
  109.  *                                *
  110.  ****************************************************************/
  111. putxpoint (x, y)
  112. float   x,
  113.         y;
  114. {
  115.     if(version == SUN_GREMLIN)
  116.       fprintf (outfile, "VECTOR\n");
  117.     else
  118.       fprintf (outfile, "%d\n", LINE);
  119.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y + cg.symbolsz);
  120.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  121.     fprintf (outfile, "%4.1f %4.1f\n", x, y);
  122.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y + cg.symbolsz);
  123.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y - cg.symbolsz);
  124.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  125.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  126. }
  127.  
  128. /****************************************************************
  129.  *                                *
  130.  *    puttripoint - draw a triangle on the point        *
  131.  *                x, y - point to use as center    *
  132.  *                                *
  133.  ****************************************************************/
  134. puttripoint (x, y)
  135. float   x,
  136.         y;
  137. {
  138.     if(version == SUN_GREMLIN)
  139.       fprintf (outfile, "VECTOR\n");
  140.     else
  141.       fprintf (outfile, "%d\n", LINE);
  142.     fprintf (outfile, "%4.1f %4.1f\n", x, y + cg.symbolsz);
  143.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  144.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y - cg.symbolsz);
  145.     fprintf (outfile, "%4.1f %4.1f\n", x, y + cg.symbolsz);
  146.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  147.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  148. }
  149.  
  150. /****************************************************************
  151.  *                                *
  152.  *    pututripoint - draw an upside down triangle        *
  153.  *                x, y - point to use as center    *
  154.  *                                *
  155.  ****************************************************************/
  156. pututripoint (x, y)
  157. float   x,
  158.         y;
  159. {
  160.     if(version == SUN_GREMLIN)
  161.       fprintf (outfile, "VECTOR\n");
  162.     else
  163.       fprintf (outfile, "%d\n", LINE);
  164.     fprintf (outfile, "%4.1f %4.1f\n", x, y - cg.symbolsz);
  165.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y + cg.symbolsz);
  166.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y + cg.symbolsz);
  167.     fprintf (outfile, "%4.1f %4.1f\n", x, y - cg.symbolsz);
  168.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  169.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  170. }
  171.  
  172. /****************************************************************
  173.  *                                *
  174.  *    putxboxpoint - draw a crossed box on the point        *
  175.  *                x, y - point to use as center    *
  176.  *                                *
  177.  ****************************************************************/
  178. putxboxpoint (x, y)
  179. float   x,
  180.         y;
  181. {
  182.     if(version == SUN_GREMLIN)
  183.       fprintf (outfile, "VECTOR\n");
  184.     else
  185.       fprintf (outfile, "%d\n", LINE);
  186.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  187.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y + cg.symbolsz);
  188.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y + cg.symbolsz);
  189.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y - cg.symbolsz);
  190.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  191.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y + cg.symbolsz);
  192.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  193.     fprintf (outfile, "%4.1f %4.1f\n", x, y);
  194.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y + cg.symbolsz);
  195.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y - cg.symbolsz);
  196.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  197.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  198. }
  199.  
  200. /****************************************************************
  201.  *                                *
  202.  *    putcboxpoint - draw a starred box on the point        *
  203.  *                x, y - point to use as center    *
  204.  *                                *
  205.  ****************************************************************/
  206. putcboxpoint (x, y)
  207. float   x,
  208.         y;
  209. {
  210.     if(version == SUN_GREMLIN)
  211.       fprintf (outfile, "VECTOR\n");
  212.     else
  213.       fprintf (outfile, "%d\n", LINE);
  214.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  215.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y + cg.symbolsz);
  216.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y + cg.symbolsz);
  217.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y - cg.symbolsz);
  218.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y - cg.symbolsz);
  219.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y);
  220.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y);
  221.     fprintf (outfile, "%4.1f %4.1f\n", x, y);
  222.     fprintf (outfile, "%4.1f %4.1f\n", x, y + cg.symbolsz);
  223.     fprintf (outfile, "%4.1f %4.1f\n", x, y - cg.symbolsz);
  224.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  225.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  226. }
  227.  
  228. /****************************************************************
  229.  *                                *
  230.  *    putdiapoint - draw a diamond on the point        *
  231.  *                x, y - point to use as center    *
  232.  *                                *
  233.  ****************************************************************/
  234. putdiapoint (x, y)
  235. float   x,
  236.         y;
  237. {
  238.     if(version == SUN_GREMLIN)
  239.       fprintf (outfile, "VECTOR\n");
  240.     else
  241.       fprintf (outfile, "%d\n", LINE);
  242.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y);
  243.     fprintf (outfile, "%4.1f %4.1f\n", x , y - cg.symbolsz);
  244.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y);
  245.     fprintf (outfile, "%4.1f %4.1f\n", x, y + cg.symbolsz);
  246.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y);
  247.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  248.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  249. }
  250.  
  251. /****************************************************************
  252.  *                                *
  253.  *    putcdiapoint - draw a crossed diamond on the point    *
  254.  *                x, y - point to use as center    *
  255.  *                                *
  256.  ****************************************************************/
  257. putcdiapoint (x, y)
  258. float   x,
  259.         y;
  260. {
  261.     if(version == SUN_GREMLIN)
  262.       fprintf (outfile, "VECTOR\n");
  263.     else
  264.       fprintf (outfile, "%d\n", LINE);
  265.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y);
  266.     fprintf (outfile, "%4.1f %4.1f\n", x , y - cg.symbolsz);
  267.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y);
  268.     fprintf (outfile, "%4.1f %4.1f\n", x, y + cg.symbolsz);
  269.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y);
  270.     fprintf (outfile, "%4.1f %4.1f\n", x, y + cg.symbolsz);
  271.     fprintf (outfile, "%4.1f %4.1f\n", x, y - cg.symbolsz);
  272.     fprintf (outfile, "%4.1f %4.1f\n", x, y);
  273.     fprintf (outfile, "%4.1f %4.1f\n", x + cg.symbolsz, y);
  274.     fprintf (outfile, "%4.1f %4.1f\n", x - cg.symbolsz, y);
  275.     fprintf(outfile, (version == SUN_GREMLIN) ? "*\n" : "-1.00 -1.00\n");
  276.     fprintf (outfile, "%d %d\n%d\n", BRUSH_NORMAL, 0, 0);
  277. }
  278.  
  279. draw_symbol(symtype, symx, symy)
  280. int symtype;
  281. float symx, symy;
  282. {
  283.     switch (symtype) {
  284.     case BOX: 
  285.         putboxpoint (symx, symy);
  286.         break;
  287.     case RING: 
  288.         putcirclepoint (symx, symy);
  289.         break;
  290.     case CROSS: 
  291.         putcrosspoint (symx, symy);
  292.         break;
  293.     case STAR: 
  294.         putxpoint (symx, symy);
  295.         break;
  296.     case TRIANGLE: 
  297.         puttripoint (symx, symy);
  298.         break;
  299.     case UTRIANGLE: 
  300.         pututripoint (symx, symy);
  301.         break;
  302.     case CROSSBOX: 
  303.         putcboxpoint (symx, symy);
  304.         break;
  305.     case STARBOX: 
  306.         putxboxpoint (symx, symy);
  307.         break;
  308.     case DIAMOND: 
  309.         putdiapoint (symx, symy);
  310.         break;
  311.     case CROSSDIAMOND: 
  312.         putcdiapoint (symx, symy);
  313.         break;
  314.     case NOSYMBOL: 
  315.     default: 
  316.         break;
  317.     }
  318. }
  319. @
  320.